package org.gnyxy.mapper;

import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.gnyxy.dto.PageQueryDTO;
import org.gnyxy.entity.Dish;
import org.gnyxy.entity.Type;
import org.gnyxy.vo.DishVO;
import org.gnyxy.vo.DishWithInfoVO;

import java.util.List;

@Mapper
public interface DishMapper {

    void insert(Dish dish);

    void update(Dish dish);

    @Select("SELECT * FROM dish WHERE id = #{id} and deleted = 0")
    Dish getById(Long id);

    DishVO getDishVOById(Long id);

    Page<Dish> pageQuery(PageQueryDTO pageQueryDTO);

    DishWithInfoVO getDishWithTypeNameVOById(Long id);

    @Select("select * from dish where deleted = 0 and status = #{status} and type_id = #{typeId}")
    List<Dish> getByTypeIdAndStatus(Dish dish);

//    @Select("select * from dish where deleted = 0 and status = 1 and name = #{name};")
    List<Dish> getByName(String name);
    @Select("select * from dish where deleted = 0 and status = 1 order by id desc ")
    List<Dish> getAll();

//    @Select("select * from dish where deleted = 0 and status = 1 and id = #{id}")
    DishWithInfoVO getByIdAndStatus(Long id);

    @Select("select name from dish where id = #{id} and deleted = 0 and status = 1")
    String getNameById(Long id);


    List<Dish> getByIds(List<Long> dishIds);
}
